/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import type.AddressType;

/**
 *
 * @author wei
 */
//
@Entity(name="Address")
public class AddressEntity extends DataObjectEntity implements Serializable {

    private String streetAddress;
    private String country;
    private String stateOrProvice;
    private String city;
    private String zipCode;
    private AddressType type;
    
    @ManyToOne
    private ContactEntity contact;
    
    public AddressEntity() {
        super();
    }

    public AddressEntity(String streetAddress, String country, String stateOrProvice, String city, String zipCode) {
        super();
        this.streetAddress = streetAddress;
        this.country = country;
        this.stateOrProvice = stateOrProvice;
        this.city = city;
        this.zipCode = zipCode;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getStateOrProvice() {
        return stateOrProvice;
    }

    public void setStateOrProvice(String stateOrProvice) {
        this.stateOrProvice = stateOrProvice;
    }

    public String getStreetAddress() {
        return streetAddress;
    }

    public void setStreetAddress(String streetAddress) {
        this.streetAddress = streetAddress;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public ContactEntity getContact() {
        return contact;
    }

    public void setContact(ContactEntity contact) {
        this.contact = contact;
    }

    public AddressType getType() {
        return type;
    }

    public void setType(AddressType type) {
        this.type = type;
    }
    
    public String getAddress(){
        String add = streetAddress + "\n" 
                + city + ", " + stateOrProvice + "\n"  
                 + country + ", " + zipCode;
        return add;
    }

    @Override
    public String toString() {
        return streetAddress + ", " + city + ", " + stateOrProvice + ", "  
                 + country + ", " + zipCode;
    }
    

    @Override
    public String childToString() {
        return "AddressEntity{" + "streetAddress=" + streetAddress + ", country=" + country + ", stateOrProvice=" + stateOrProvice + ", city=" + city + ", zipCode=" + zipCode + ", type=" + type + ", contact=" + contact + '}';
    }
    
}
